import watcher from "./watcher"

export default class Dep  {
    constructor() {
        this.subs = []
    }
    // 收集watcher
    depend() {
        this.subs.push(Dep.target)
    }
    // 更新
    notify() {
        this.subs.forEach(watcher => {
            watcher.updata()
        })
    }
}

Dep.target = null
// 添加watcher
export function pushTarget(watcher) {
    Dep.target = watcher
}

export function popTarget() {

}